/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sisgraf.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
/**
 *
 * @author Jordan de Carvalho Guerra
 */
@Entity
public class Vendedor implements Serializable  {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    private Integer id;
    private String mat_ven;
    private String nom_ven;
    private String ativo;
    private String end_log;
    private Integer end_num;
    private String end_com;
    private String end_bai;
    private Integer end_cep;
    private String end_cid;
    private String end_uf;
    private String email;
    private String tel_fix;
    private String tel_cel;
    private BigDecimal com_ven;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dat_nas;
    @JoinColumn(name = "idUsr", referencedColumnName = "id",nullable = true)
    @ManyToOne(optional=false)
    private Usuario usuario;

    public Vendedor() {
        this.id = null;
        this.mat_ven = null;
        this.nom_ven = null;
        this.ativo = null;
        this.end_log = null;
        this.end_num = null;
        this.end_com = null;
        this.end_bai = null;
        this.end_cep = null;
        this.end_cid = null;
        this.end_uf = null;
        this.email = null;
        this.tel_fix = null;
        this.tel_cel = null;
        this.com_ven = null;
        this.dat_nas = null;
        this.usuario=new Usuario();
    }

    public String getAtivo() {
        return ativo;
    }
    public String getAtivoDes() {
        if (ativo.equals("S"))
           return "Sim";
        else if (ativo.equals("N"))
           return "Não";
        else
           return ativo;
    }

    public void setAtivo(String ativo) {
        this.ativo = ativo;
    }

    public String getCom_ven() {
        if (com_ven == null)
            return "";
        else
            return com_ven.toString();
    }
    public BigDecimal getComVen() {
        return com_ven;
    }

    public void setCom_ven(String com_ven) {
        this.com_ven = new BigDecimal(com_ven);
    }

    public Date getDat_nas() {
        return dat_nas;
    }
    public String getDat_nasForm() {
        String data="  /  /    ";
        if (this.dat_nas!=null){
            SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
            data = formato.format(this.dat_nas);
        }
        return data;
    }

    public void setDat_nas(String dat_nas) {
        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy");
        java.util.Date data=null;

        try {
            data = formato.parse(dat_nas);
        } catch (ParseException ex) {
            data=null;
        } finally {
            this.dat_nas = data;
        }
    }
    public void setDat_nas(Date dat_nas) {
        this.dat_nas = dat_nas;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEnd_bai() {
        return end_bai;
    }

    public void setEnd_bai(String end_bai) {
        this.end_bai = end_bai;
    }

    public Integer getEnd_cep() {
        return end_cep;
    }

    public void setEnd_cep(Integer end_cep) {
        this.end_cep = end_cep;
    }

    public String getEnd_cid() {
        return end_cid;
    }

    public void setEnd_cid(String end_cid) {
        this.end_cid = end_cid;
    }

    public String getEnd_com() {
        return end_com;
    }

    public void setEnd_com(String end_com) {
        this.end_com = end_com;
    }

    public String getEnd_log() {
        return end_log;
    }

    public void setEnd_log(String end_log) {
        this.end_log = end_log;
    }

    public Integer getEnd_num() {
        return end_num;
    }

    public void setEnd_num(Integer end_num) {
        this.end_num = end_num;
    }

    public String getEnd_uf() {
        return end_uf;
    }

    public void setEnd_uf(String end_uf) {
        this.end_uf = end_uf;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getMat_ven() {
        return mat_ven;
    }

    public void setMat_ven(String mat_ven) {
        this.mat_ven = mat_ven;
    }

    public String getNom_ven() {
        return nom_ven;
    }

    public void setNom_ven(String nom_ven) {
        this.nom_ven = nom_ven;
    }

    public String getTel_cel() {
        return tel_cel;
    }

    public void setTel_cel(String tel_cel) {
        this.tel_cel = tel_cel;
    }

    public String getTel_fix() {
        return tel_fix;
    }

    public void setTel_fix(String tel_fix) {
        this.tel_fix = tel_fix;
    }
    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

}
